package com.reserv.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Timestamp;
import java.util.ArrayList;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;
import com.reserv.dao.CommentDAO;
import com.reserv.dao.ReservDAO;
import com.reserv.util.TimestampUtil;
import com.reserv.vo.CommentVO;


public class GetReservServlet extends HttpServlet {
	private ReservDAO dao;
	@Override
	public void init(ServletConfig config) throws ServletException {
		dao = ReservDAO.getInstance();
		
	}
	private void doProcess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int sno = Integer.parseInt(request.getParameter("sno"));
		
		ArrayList<Timestamp> list = (ArrayList<Timestamp>) dao.getReservList(sno);
		
		Gson gson = new Gson();
		String json = gson.toJson(list);
		
		System.out.println(json);
		
		PrintWriter out = response.getWriter();
		out.println(json);
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doProcess(request, response);
	}
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doProcess(request, response);
	}
}
